<h2 ALIGN="center" STYLE="font-weight: bold; color: black; font-size: large;">BÁO CÁO CÔNG NỢ THEO THÁNG</h2>
<h1 ALIGN="center">Tháng <?php echo $THANG ?></h1>
<table>
    <tr>
        <th>MÃ KH</th>
        <th>NGÀY NỢ</th>
        <th>TIỀN NỢ</th>
    </tr>

    <?php foreach ($kqas as $kqa): ?>
        <tr>
            <td><?php echo $kqa['hoadonban']['MAKH'];?></td>
            <td><?php echo $kqa['hoadonban']['NGAYBAN'];?></td>
            <td><?php echo $kqa['0']['TIENNO'];?></td>
        </tr>
    <?php endforeach; ?>

    <?php foreach ($kqcs as $kqc):?>
        <tr>
            <td>TỔNG NỢ</td>
            <td></td>
            <td><?php echo $kqc['0']['TONGNO'];?></td>
        </tr>
    <?php endforeach; ?>

    <tr>
            <th>ID</th>
            <th>Ngày thanh toán</th>
            <thTiền thanh toán</th>

    </tr>

    <?php foreach ($kqbs as $kqb): ?>
        <tr>
            <td><?php echo $kqb['thanhtoan']['MAKH'];?></td>
            <td><?php echo $kqb['thanhtoan']['NGAYTHANHTOAN'];?></td>
            <td><?php echo $kqb['thanhtoan']['SOTIENTHANHTOAN'];?></td>
        </tr>
    <?php endforeach; ?>

    <?php foreach ($kqds as $kqd):?>
        <tr>
            <td>TỔNG THANH TOÁN</td>
            <td></td>
            <td><?php echo $kqd['0']['TONGTHANHTOAN'];?></td>
         </tr>

         <?php foreach ($kqcs as $kqc):?>
                 <tr>
                     <th>TỔNG NỢ CỦA KHÁCH TRONG THÁNG</th>
                     <th></th>
                     <th><?php echo ($kqc['0']['TONGNO']- $kqd['0']['TONGTHANHTOAN']);?></th>
                 </tr>
             <?php endforeach; ?>

    <?php endforeach; ?>

</table>



